<?php
namespace Twoir\Controller;

use Twoir\Service\BaseMember;
use Twoir\Service\Member\Login;
use Twoir\Service\Member\Register;
use Twoir\Service\Member\Widgets;
use Twoir\Service\ShowKey\Image;

/**
 * 会员模块
 *
 * 功能有：登陆、注册、退出等
 *
 * 2022.01.31
 * update 2024.05.06 cighsne02 365182575
 */
class Member
{
    const VERSION = '1.5.3';

    /**
     * 用户登陆
     *
     * @param array $add POST对象
     * @return array|throw
    */
    public static function login($add)
    {
		return call_user_func_array([new Login, 'userName'], [$add]);
    }

    /**
     * 用户注册
     *
     * @param array $add POST对象
     * @return array|throw
    */
    public static function register($add)
    {
		// 用户注册
		return call_user_func_array([new Register, 'userName'], [$add]);
    }

    /**
     * 退出登陆
    */
    public static function logout()
    {
        call_user_func([new BaseMember, __FUNCTION__]);
    }

    /**
     * 获取验证码
    */
    public static function showKey($add)
    {
        return call_user_func_array([new Image, 'render'], [$add]);
    }

    /**
     * 增加收藏
     *
     * @param array $add
     * @return array
    */
    public static function setFava($add)
    {
        return call_user_func_array([new Widgets, __FUNCTION__], [$add]);
    }

	/**
	 * 方法不存在时 404
	 *
	 * @param $name
	 * @param $parameters
	 * @return throw
	*/
	public static function __callStatic($name, $parameters)
	{
		 throw new \Exception('参数错误', 9200);
	}
}
